home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / ctl3dpas.zip / SAMPLE3D.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-04  |  3KB  |  116 lines

  1. (**************************************************)
  2. (*                                                *)
  3. (*   Sample3D - Shows the use of CTL3D.DLL        *)
  4. (*                                                *)
  5. (*   Supplied by Andreas Furrer                   *)
  6. (*                                                *)
  7. (**************************************************)
  8.  
  9. program Sample3D;
  10.  
  11. {$R sample3d.res}
  12.  
  13.  
  14. uses WinTypes, WinProcs, WObjects, CommDlg, Ctl3d;
  15.  
  16. type
  17.    Applikation =
  18.       object(TApplication)
  19.          procedure InitMainWindow; virtual;
  20.       end;
  21.  
  22.    PMainwindow = ^TMainwindow;
  23.    TMainwindow =
  24.       object(TDialog)
  25.          procedure WMDlgBorder(var Msg : TMessage); virtual wm_DlgBorder;
  26.          procedure WMDlgSubclass(var Msg : TMessage); virtual wm_DlgSubclass;
  27.          procedure WMSysColorChange(var Msg : TMessage); virtual wm_first + wm_SysColorChange;
  28.          procedure Msgbox(var Msg : TMessage);   virtual id_first + 130;
  29.          procedure Fileopen(var Msg : TMessage); virtual id_first + 131;
  30.       end;
  31.  
  32.  
  33.  
  34. procedure TMainwindow.WMDlgBorder;
  35. begin
  36. { Remove the comments from the next block of code to      }
  37. { stop the dialog border form being drawn with 3D effects }
  38. {
  39.   PInteger(Msg.lParam)^ := Ctl3d_NoBorder;
  40. }
  41. end;
  42.  
  43. procedure TMainwindow.WMDlgSubclass;
  44. begin
  45. { Remove the comments from the next block of code to      }
  46. { stop subclassing the controls on this dialog            }
  47. {
  48.   PInteger(Msg.lParam)^ := Ctl3d_NoSubclass;
  49. }
  50. end;
  51.  
  52. procedure TMainwindow.WMSysColorChange;
  53. begin
  54.   Ctl3dColorChange;
  55. end;
  56.  
  57. procedure TMainwindow.Msgbox;
  58. begin
  59.   MessageBox(HWindow,'This is a sample Message Box','3D Look',mb_Ok);
  60. end;
  61.  
  62.  
  63. function HookProc(HWindow: HWnd; Msg, wParam: word; lParam: longint): word;far;
  64. var p : TFarProc;
  65. begin
  66.   IF Msg=wm_InitDialog then begin
  67.     Ctl3dSubClassDlg(HWindow,Ctl3d_All);
  68.   end;
  69.   HookProc:=0;
  70. end;
  71.  
  72. procedure TMainwindow.Fileopen;
  73. var FileName : array[0..255] of char;
  74.     Ofn :  TOpenFileName;
  75. begin
  76.   FileName[0]:=#0;
  77.   Ofn.lStructSize       := sizeof(TOpenFileName);
  78.   Ofn.hwndOwner         := HWindow;
  79.   Ofn.hInstance         := HInstance;
  80.   Ofn.lpstrFilter       :='Text Files (*.TXT)'+#0+'*.TXT'+#0+'All Files (*.*)'+#0+'*.*'+#0+#0;
  81.   Ofn.lpstrCustomFilter := nil;
  82.   Ofn.nMaxCustFilter    := 0;
  83.   Ofn.nFilterIndex      := 1;
  84.   Ofn.lpstrFile         := FileName;
  85.   Ofn.nMaxFile          := sizeof(FileName);
  86.   Ofn.lpstrFileTitle    := nil;
  87.   Ofn.nMaxFileTitle     := 0;
  88.   Ofn.lpstrInitialDir   := nil;
  89.   Ofn.lpstrTitle        := '3D Look';
  90.   Ofn.Flags             := ofn_HideReadonly or ofn_EnableHook;
  91.   Ofn.nFileOffset       := 0;
  92.   Ofn.nFileExtension    := 0;
  93.   Ofn.lpstrDefExt       := NIL;
  94.   Ofn.lpTemplateName    := 'FileOpen';
  95.   Ofn.lCustData         := 0;
  96.   Ofn.lpfnHook         := HookProc;
  97.   GetOpenFileName(Ofn);
  98. end;
  99.  
  100. procedure Applikation.InitMainWindow;
  101. begin
  102.   MainWindow := New(PMainwindow, Init(nil, MakeIntResource(100)));
  103. end;
  104.  
  105. var Prg : Applikation;
  106.  
  107. begin
  108.    Ctl3dRegister(HInstance);
  109.    Ctl3dAutoSubclass(HInstance);
  110.  
  111.    Prg.Init('Sample3D');
  112.    Prg.Run;
  113.    Prg.Done;
  114.  
  115.    Ctl3dUnregister(HInstance);
  116. end.